program q1008;
var
    n, i, ans, last, t, distance: integer;
begin
    assign(input, '');
    assign(output, '');
    reset(input);
    rewrite(output);

    while not eof do
        begin
        read(n);
        if (0 = n) then break;
        ans := n * 5;

        last := 0;
        for i:=1 to n do
            begin
            read(t);
            distance := last - t;

            if (distance > 0) then
                ans := ans + distance * 4
            else
                ans := ans + abs(distance) * 6;

            last := t;
            end;

        writeln(ans);
        end;

    close(input);
    close(output);
end.
